package com.mt.roll.wms.dispatch.enums.machineHand1;


import com.mt.roll.opcua.s7.my.s7connector.api.DaveArea;
import com.mt.roll.opcua.s7.my.s7connector.type.PlcVar;
import com.mt.roll.wms.dispatch.constant.BusinessConstant;
import com.mt.roll.wms.dispatch.enums.CodeEnum;

/**
 * @Author: 蔡翔
 * @Date: 2019/10/14 10:06
 * @Version 1.0
 */
//实际 Plc中的变量。。。  要实现录入到这个枚举类中。。。 为后续做准备。
//注意：
//      ① 单体变量  length 都是1
//      ② 数组变量  length 就是 你要read 或者write数组的长度
//      ③ bitOffset 是针对Bool 来说的，其他变量bitOffset 都是0
//      ④ strSize 这个字段只是给 String变量 和 String[]变量 用的, 这个字段是plc中设置的最大String长度
//      ⑤ String类型 在write的时候禁止 write中文，因为plc中编码并没有采用UTF-8 而是采用ASCII
// （同理也是，当plc中有设置String类型或者StringArray那么告诉他们必须指定长度 通常他们也会指定长度的。）
public enum MachineHand1Plc2WcsVarEnum implements CodeEnum {
    /**
     * 命名规则：L_1_IN_1_SFTOCKULL  ;
     *              //① L_1代表库位编号1，
     *              ② IN代表in口（下片） / OUT 代表 out口 （上片）
     *              ③ 1 代表 working port 1（左下1 左下2，左上3，做上4）
     *              ④ SFTOCKULL 就代表具体变量含义
     **/

    SubIdArrays1200("SubIdArrays1200",DaveArea.DB,1,20,0,PlcVar.STRING_Array,60,18,1,"1"),


    // 需要改areaNumber 、 byteOffset 、 bitOffset   ,, 如果是String 数组 那么需要改length(数组长度)、strSize(每个字符串变量长度)
    IN_1_STOCKFULL("STOCKFULL",DaveArea.DB,1,0,0,PlcVar.BOOL,1, BusinessConstant.machineHand1_IN_1_LOCATION_ID,"箱子满料，标志位，满料==1.没满料==0"),
    IN_1_ROT_ID("ROT_ID",DaveArea.DB,1,2,0,PlcVar.INT,1,BusinessConstant.machineHand1_IN_1_LOCATION_ID,"机械手id"),
    IN_1_STOCK_ID("STOCK_ID",DaveArea.DB,1,4,0,PlcVar.STRING,1,10,BusinessConstant.machineHand1_IN_1_LOCATION_ID,"箱子id"),
    IN_1_PLATE_NUB("PLATE_NUB",DaveArea.DB,1,16,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_IN_1_LOCATION_ID,"标志位触发后箱子中基板数量"),
    IN_1_STATE("STATE",DaveArea.DB,1,18,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_IN_1_LOCATION_ID,"箱子中基板状态，OK==10，,NG==20"),
    IN_1_SUB_ID_ARRAY("SUB_ID_ARRAY",DaveArea.DB,1,20,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_IN_1_LOCATION_ID,"箱子中基板 二维码数组，从下往上数1-60，按顺序"),
    IN_1_Time_ARRAY("Time_ARRAY",DaveArea.DB,1,1240,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_IN_1_LOCATION_ID,"机械手抓取基板的时间，数组。"),

    IN_2_STOCKFULL("STOCKFULL",DaveArea.DB,3,3267,0,PlcVar.BOOL,1,BusinessConstant.machineHand1_IN_2_LOCATION_ID,"箱子满料，标志位，满料==1.没满料==0"),
    IN_2_ROT_ID("ROT_ID",DaveArea.DB,3,3267,0,PlcVar.INT,1,BusinessConstant.machineHand1_IN_2_LOCATION_ID,"机械手id"),
    IN_2_STOCK_ID("STOCK_ID",DaveArea.DB,3,3267,0,PlcVar.STRING,1,10,BusinessConstant.machineHand1_IN_2_LOCATION_ID,"箱子id"),
    IN_2_PLATE_NUB("PLATE_NUB",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_IN_2_LOCATION_ID,"标志位触发后箱子中基板数量"),
    IN_2_STATE("STATE",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_IN_2_LOCATION_ID,"箱子中基板状态，OK==10，,NG==20"),
    IN_2_SUB_ID_ARRAY("SUB_ID_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_IN_2_LOCATION_ID,"箱子中基板 二维码数组，从下往上数1-60，按顺序"),
    IN_2_Time_ARRAY("Time_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_IN_2_LOCATION_ID,"机械手抓取基板的时间，数组。"),

    IN_3_STOCKFULL("STOCKFULL",DaveArea.DB,3,3267,0,PlcVar.BOOL,1,BusinessConstant.machineHand1_IN_3_LOCATION_ID,"箱子满料，标志位，满料==1.没满料==0"),
    IN_3_ROT_ID("ROT_ID",DaveArea.DB,3,3267,0,PlcVar.INT,1,BusinessConstant.machineHand1_IN_3_LOCATION_ID,"机械手id"),
    IN_3_STOCK_ID("STOCK_ID",DaveArea.DB,3,3267,0,PlcVar.STRING,1,10,BusinessConstant.machineHand1_IN_3_LOCATION_ID,"箱子id"),
    IN_3_PLATE_NUB("PLATE_NUB",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_IN_3_LOCATION_ID,"标志位触发后箱子中基板数量"),
    IN_3_STATE("STATE",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_IN_3_LOCATION_ID,"箱子中基板状态，OK==10，,NG==20"),
    IN_3_SUB_ID_ARRAY("SUB_ID_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_IN_3_LOCATION_ID,"箱子中基板 二维码数组，从下往上数1-60，按顺序"),
    IN_3_Time_ARRAY("Time_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_IN_3_LOCATION_ID,"机械手抓取基板的时间，数组。"),

    IN_4_STOCKFULL("STOCKFULL",DaveArea.DB,3,3267,0,PlcVar.BOOL,1,BusinessConstant.machineHand1_IN_4_LOCATION_ID,"箱子满料，标志位，满料==1.没满料==0"),
    IN_4_ROT_ID("ROT_ID",DaveArea.DB,3,3267,0,PlcVar.INT,1,BusinessConstant.machineHand1_IN_4_LOCATION_ID,"机械手id"),
    IN_4_STOCK_ID("STOCK_ID",DaveArea.DB,3,3267,0,PlcVar.STRING,1,10,BusinessConstant.machineHand1_IN_4_LOCATION_ID,"箱子id"),
    IN_4_PLATE_NUB("PLATE_NUB",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_IN_4_LOCATION_ID,"标志位触发后箱子中基板数量"),
    IN_4_STATE("STATE",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_IN_4_LOCATION_ID,"箱子中基板状态，OK==10，,NG==20"),
    IN_4_SUB_ID_ARRAY("SUB_ID_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_IN_4_LOCATION_ID,"箱子中基板 二维码数组，从下往上数1-60，按顺序"),
    IN_4_Time_ARRAY("Time_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_IN_4_LOCATION_ID,"机械手抓取基板的时间，数组。"),



    OUT_1_STOCKEMPTY("STOCKEMPTY",DaveArea.DB,3,3267,0,PlcVar.BOOL,1,BusinessConstant.machineHand1_OUT_1_LOCATION_ID,"箱子空箱，标志位，空料==1.未空==0"),
    OUT_1_ROT_ID("ROT_ID",DaveArea.DB,3,3267,0,PlcVar.INT,1,BusinessConstant.machineHand1_OUT_1_LOCATION_ID,"机械手id"),
    OUT_1_STOCK_ID("STOCK_ID",DaveArea.DB,3,3267,0,PlcVar.STRING,1,10,BusinessConstant.machineHand1_OUT_1_LOCATION_ID,"箱子id"),
    OUT_1_PLATE_NUB("PLATE_NUB",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_OUT_1_LOCATION_ID,"标志位触发后箱子中基板数量"),
    OUT_1_STATE("STATE",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_OUT_1_LOCATION_ID,"箱子中基板状态，OK==10，,NG==20"),
    OUT_1_SUB_ID_ARRAY("SUB_ID_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_OUT_1_LOCATION_ID,"箱子中基板 二维码数组，从下往上数1-60，按顺序"),
    OUT_1_Time_ARRAY("Time_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_OUT_1_LOCATION_ID,"机械手抓取基板的时间，数组。"),

    OUT_2_STOCKEMPTY("STOCKEMPTY",DaveArea.DB,3,3267,0,PlcVar.BOOL,1,BusinessConstant.machineHand1_OUT_2_LOCATION_ID,"箱子空箱，标志位，空料==1.未空==0"),
    OUT_2_ROT_ID("ROT_ID",DaveArea.DB,3,3267,0,PlcVar.INT,1,BusinessConstant.machineHand1_OUT_2_LOCATION_ID,"机械手id"),
    OUT_2_STOCK_ID("STOCK_ID",DaveArea.DB,3,3267,0,PlcVar.STRING,1,10,BusinessConstant.machineHand1_OUT_2_LOCATION_ID,"箱子id"),
    OUT_2_PLATE_NUB("PLATE_NUB",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_OUT_2_LOCATION_ID,"标志位触发后箱子中基板数量"),
    OUT_2_STATE("STATE",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_OUT_2_LOCATION_ID,"箱子中基板状态，OK==10，,NG==20"),
    OUT_2_SUB_ID_ARRAY("SUB_ID_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_OUT_2_LOCATION_ID,"箱子中基板 二维码数组，从下往上数1-60，按顺序"),
    OUT_2_Time_ARRAY("Time_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_OUT_2_LOCATION_ID,"机械手抓取基板的时间，数组。"),

    OUT_3_STOCKEMPTY("STOCKEMPTY",DaveArea.DB,3,3267,0,PlcVar.BOOL,1,BusinessConstant.machineHand1_OUT_3_LOCATION_ID,"箱子空箱，标志位，空料==1.未空==0"),
    OUT_3_ROT_ID("ROT_ID",DaveArea.DB,3,3267,0,PlcVar.INT,1,BusinessConstant.machineHand1_OUT_3_LOCATION_ID,"机械手id"),
    OUT_3_STOCK_ID("STOCK_ID",DaveArea.DB,3,3267,0,PlcVar.STRING,1,10,BusinessConstant.machineHand1_OUT_3_LOCATION_ID,"箱子id"),
    OUT_3_PLATE_NUB("PLATE_NUB",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_OUT_3_LOCATION_ID,"标志位触发后箱子中基板数量"),
    OUT_3_STATE("STATE",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_OUT_3_LOCATION_ID,"箱子中基板状态，OK==10，,NG==20"),
    OUT_3_SUB_ID_ARRAY("SUB_ID_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_OUT_3_LOCATION_ID,"箱子中基板 二维码数组，从下往上数1-60，按顺序"),
    OUT_3_Time_ARRAY("Time_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_OUT_3_LOCATION_ID,"机械手抓取基板的时间，数组。"),

    OUT_4_STOCKEMPTY("STOCKEMPTY",DaveArea.DB,3,3267,0,PlcVar.BOOL,1,BusinessConstant.machineHand1_OUT_4_LOCATION_ID,"箱子空箱，标志位，空料==1.未空==0"),
    OUT_4_ROT_ID("ROT_ID",DaveArea.DB,3,3267,0,PlcVar.INT,1,BusinessConstant.machineHand1_OUT_4_LOCATION_ID,"机械手id"),
    OUT_4_STOCK_ID("STOCK_ID",DaveArea.DB,3,3267,0,PlcVar.STRING,1,10,BusinessConstant.machineHand1_OUT_4_LOCATION_ID,"箱子id"),
    OUT_4_PLATE_NUB("PLATE_NUB",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_OUT_4_LOCATION_ID,"标志位触发后箱子中基板数量"),
    OUT_4_STATE("STATE",DaveArea.DB,3,3267,0,PlcVar.INT,1,0,BusinessConstant.machineHand1_OUT_4_LOCATION_ID,"箱子中基板状态，OK==10，,NG==20"),
    OUT_4_SUB_ID_ARRAY("SUB_ID_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_OUT_4_LOCATION_ID,"箱子中基板 二维码数组，从下往上数1-60，按顺序"),
    OUT_4_Time_ARRAY("Time_ARRAY",DaveArea.DB,3,3267,0,PlcVar.STRING_Array,60,18,BusinessConstant.machineHand1_OUT_4_LOCATION_ID,"机械手抓取基板的时间，数组。"),


    ;
    private String name;
    private DaveArea area;
    private Integer areaNumber;
    private Integer byteOffset;
    private Integer bitOffset;
    private PlcVar type;
    //length = 1代表 非数组;;;       length > 1 代表数组  ;; 注意 length这个参数 是实际plc中 数组的长度，和read操作相关
    //如果是String 类型不用填length 只需要填string类型的起始位置就行了，我会自己去取数据长度（也就是说这里的length并不是string 的长度）。
    private Integer length;

    //这个字段只是给 字符串变量 和 字符串数组 用, 这个字段是plc中设置的最大String长度
    private Integer strSize;
    private Integer locationNum;
    private String desc;


    MachineHand1Plc2WcsVarEnum() {
    }

    MachineHand1Plc2WcsVarEnum(String name, DaveArea area, Integer areaNumber, Integer byteOffset, Integer bitOffset, PlcVar type, Integer length, Integer strSize, Integer locationNum, String desc) {
        this.name = name;
        this.area = area;
        this.areaNumber = areaNumber;
        this.byteOffset = byteOffset;
        this.bitOffset = bitOffset;
        this.type = type;
        this.length = length;
        this.strSize = strSize;
        this.locationNum = locationNum;
        this.desc = desc;
    }

    MachineHand1Plc2WcsVarEnum(String name, DaveArea area, Integer areaNumber, Integer byteOffset, Integer bitOffset, PlcVar type, Integer length, Integer locationNum, String desc) {
        this.name = name;
        this.area = area;
        this.areaNumber = areaNumber;
        this.byteOffset = byteOffset;
        this.bitOffset = bitOffset;
        this.type = type;
        this.length = length;
        this.locationNum = locationNum;
        this.desc = desc;
        this.strSize = 0;
    }

    public static MachineHand1Plc2WcsVarEnum getStockFullEnumByLocationNum(Integer locationNum){
        for(MachineHand1Plc2WcsVarEnum i:values()){
            if(i.getLocationNum().equals(locationNum) && i.getName().equals("STOCKFULL")){
                return i;
            }
        }
        return null;
    }

    @Override
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public DaveArea getArea() {
        return area;
    }

    public void setArea(DaveArea area) {
        this.area = area;
    }

    public Integer getAreaNumber() {
        return areaNumber;
    }

    public void setAreaNumber(Integer areaNumber) {
        this.areaNumber = areaNumber;
    }

    public Integer getByteOffset() {
        return byteOffset;
    }

    public void setByteOffset(Integer byteOffset) {
        this.byteOffset = byteOffset;
    }

    public Integer getBitOffset() {
        return bitOffset;
    }

    public void setBitOffset(Integer bitOffset) {
        this.bitOffset = bitOffset;
    }

    @Override
    public PlcVar getType() {
        return type;
    }

    public void setType(PlcVar type) {
        this.type = type;
    }

    @Override
    public Integer getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }

    @Override
    public Integer getStrSize() {
        return strSize;
    }

    public void setStrSize(Integer strSize) {
        this.strSize = strSize;
    }

    public Integer getLocationNum() {
        return locationNum;
    }

    public void setLocationNum(Integer locationNum) {
        this.locationNum = locationNum;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

}
